package it.polimi.authentication.web.beans;

import java.util.List;
import java.util.ArrayList;

import it.polimi.TravelDream.UserDTO;
import it.polimi.TravelDream.UserMgr;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;
import javax.faces.bean.ViewScoped;

@ManagedBean(name="editBean")
@SessionScoped

public class EditBean {

	@EJB
	private UserMgr usermgr;
	private UserDTO currentUser;
	
	public EditBean(){
		currentUser = new UserDTO();
	}
	
	public UserDTO getCurrentUser() {
		return currentUser;
	}
	
	public void setCurrentUser(UserDTO currentUser) {
		this.currentUser = currentUser;
	}
	
	public String searchCurrentUser() {
		currentUser = usermgr.getCurrentUserDTO();
		return "/users/EditAccount?faces-redirect=true";
	}
	
	public String updateCurrentUser() {
		usermgr.update(currentUser);
		return "/users/home?faces-redirect=true";
	}


	
	
	
	
	
	
	
}
